<?php
require_once 'includes/haut.php';
acces($niveau,1);

require_once 'modules/gestionPhoto.php';
require_once 'includes/donneesFormulaires.php';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Nouvelle cr&eacute;ation</title>
		<?php include('includes/headLinks.php');?>
		<script src="plugin/jquery.bxSlider/jquery.bxSlider.min.js" type="text/javascript"></script>
		<script type="text/javascript" src="js/ajoutCreation.js"></script>
	</head>
	<body>
		<div id="entete">
		</div>

		<div id="navigation">
			<?php include('includes/navigation.php'); ?>
		</div>

		<div id="principal">
		
			<h2>Ajouter des photos</h2>
			
		<?php if (!isset($_GET['idCreation']) && !isset($idCreation)) {
			header("Location:ajoutCreation.php");
			exit();
		}
		else if (isset($_GET['idCreation'])){
			$idCreation = $_GET['idCreation'];
		}
		if (!isset($idPhoto)) $idPhoto = 1;?>
		
			<div class="error">
				<?php if (isset($erreur) && !empty($erreur)) echo $erreur; ?>
			</div>
			
			<?php $req = photo::getPhotoByCreation($idCreation);
			if ($req->rowCount()>0) {?>	
				<div class="prefix_1 listeCreations suffix_1"
					style="margin-bottom: 30px; margin-top: 20px">
					<div class="slider">
						<script type="text/javascript">
							$(document).ready(function() {
								$('#slider').bxSlider();
							});
						</script>
						<ul id="slider">
							<li>
								<?php
								$i = 0;
								while ($res = $req->fetch()){
									if ($i % 3 == 0 && $i > 0) {?>
										</li><li>
									<?php } ?>
									<div class="elementSlider"
										style="float: left; margin: 0px 12px;">
											<img class="photo" src="images/creations/<?php echo($idCreation.'/'.$res['nom']);?>"
												style=" margin-top: -5px;" />
									</div> 
									<?php
						 			$i++;
						 		} $req->closeCursor();?>
							</li>
						</ul>
					</div>
				</div>
			<?php } ?>
			
			<form action="ajoutPhoto.php" method="post" enctype="multipart/form-data">
				<div class="formPhotos">
					<label for="photo<?php echo $idPhoto; ?>">Photo (max 3Mo) : </label>
					<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
					<input type="file" name="photo<?php echo $idPhoto; ?>" />
					<input class="submit" type="submit" name="charger" value="Charger" />
					<input type="hidden" name="action" value="photos" />
					<input type="hidden" name="idPhoto" value="<?php echo $idPhoto; ?>"/>
					<input type="hidden" name="idCreation" value="<?php echo $idCreation; ?>" />
				</div>
			</form>
			<center>
				<a href="indexAdmin.php"><img id="validation" src="images/icones/valider.png" title="OK" alt="OK"/></a>
			</center>
		</div>

		<div id="form_connexion">
			<?php include('includes/formConnexion.php'); ?>
		</div>
	</body>
</html>